/**
 * User: Phil
 * Date: 10/13/11
 * Time: 9:22 PM
 */

//Kinds of effects a card can have on the turn
var EffectTypes = {
	CARD: {value: 0, code: "CARD", name: "Card"},
	DISCARD: {value: 1, code: "DISCARD", name: "Discard"},
	MONEY: {value: 2, code: "MONEY", name: "Money"},
	TRASH: {value: 3, code: "TRASH", name: "Trash"},
	BUY: {value: 4, code: "BUY", name: "Buy"},
	ACTION: {value: 5, code: "ACTION", name: "Action"},
	GAIN_CARD: {value: 6, code: "GAIN_CARD", name: "Gain card"},
	BLOCK: {value: 7, code: "BLOCK", name: "Block"},
	TOPDECK_CARD: {value: 8, code: "TOPDECK_CARD", name: "Topdeck card"}
};

//Things that effects will affect
//SELF refers to the player's action/buy/money pool
//SELF_DECK refers to card effects
//SELF_HAND refers to discard/trash effects
var EffectTargetTypes = {
	SELF: {value: 0, code: "SELF", name: "You"},
	OPPONENT: {value: 1, code: "OPPONENT", name: "Opponent"},
	SELF_DECK: {value: 2, code: "SELF_DECK", name: "Your Deck"},
	OPPONENT_DECK: {value: 3, code: "OPPONENT_DECK", name: "Opponent's Deck"},
	SELF_HAND: {value: 4, code: "SELF_HAND", name: "Your Hand"},
	OPPONENT_HAND: {value: 5, code: "OPPONENT_DECK", name: "Opponent's Hand"},
	ALL_OPPONENTS: {value: 6, code: "ALL_OPPONENTS", name: "All Opponents"},
	THIS_CARD: {value: 7, code: "THIS_CARD", name: "This card"}
};

//Things that can trigger additional optional effects on a card
var EffectTriggerTypes = {
	STATIC: {value: 0, code: "STATIC", name: "None"},
	CARD: {value: 1, code: "CARD", name: "Card"},
	DISCARD: {value: 2, code: "DISCARD", name: "Discard"},
	BUY: {value: 3, code: "BUY", name: "Buy"},
	TRASH: {value: 4, code: "TRASH", name: "Trash"},
	ATTACK: {value: 5, code: "ATTACK", name: "Attack"},
	OPTIONAL: {value: 6, code: "OPTIONAL", name: "Optional"}
};

var EffectTrigger = Class.extend({
	//Attributes
	type: null,
	quantity: null,

	//Methods
	init: function(type, quantity) {
		this.type = type;
		this.quantity = quantity;
	}
});

var EffectTarget = Class.extend({
	//Attributes
	type: null,

	//Methods
	init: function(type) {
		this.type = type;
	}
});

var EffectQuantityTypes = {
	FIXED: {value: 0, code: "FIXED", name: "Fixed"},
	AT_LEAST: {value: 1, code: "AT_LEAST", name: "At Least"},
	UP_TO: {value: 2, code: "UP_TO", name: "Up To"}
};

var EffectConstraintTypes = {
	COSTS_UP_TO: {value: 0, code: "COSTS_UP_TO", name: "Costs up to"},
	COSTS_AT_LEAST: {value: 1, code: "COSTS_AT_LEAST", name: "Costs at least"},
	COSTS_EXACTLY: {value: 2, code: "COSTS_EXACTLY", name: "Costs exactly"},
	COSTS_LESS_THAN: {value: 3, code: "COSTS_LESS_THAN", name: "Costs less than"},
	CARD_TYPE: {value: 4, code: "CARD_TYPE", name: "Card type"}
};

//Encapsulates a restriction on an effect
//Value arg meaning is dependent on first arg
var EffectConstraint = Class.extend({
	init: function(type, value) {
		this.type = type;
		this.value = value;
	}
});

//Static effects that a card has every time it is played
//Triggers, targets are OR-related
//i.e., an effect with a targets list of SELF and OPPONENT can target yourself or your opponent
//For GAIN_CARD effects, the quantity argument should represent any cost limits, 0 for none
var Effect = Class.extend({
	//Methods
	init: function(type, quantity, quantityType, duration) {
		this.type = type;
		this.duration = duration;   //Zero means applied immediately
		this.quantity = quantity;   //How many times this effect applies

		//Attributes
		this.triggers = new Array();
		this.targets = new Array();
		this.subEffects = new Array();
		this.constraints = new Array();
		this.quantityType = null;  //Whether this quantity refers to a required number or a variable number
		this.description = null;
	}
});

